<template>
    <div style="height: 1800px">
        <mon-page-list :loading="loading" :finished="finished" @load="load">
            <newItem
                v-for="(item, index) in news"
                :title="item.title"
                :item="item"
                :key="index"
                @clickEvent="clickNews"
            />
        </mon-page-list>

        <mon-back-top />
    </div>
</template>

<script>
import newItem from "components/newsItem";
import { MonToastr as Toastr } from "mon-util";
export default {
    name: "list",
    components: {
        newItem
    },
    mounted() {
        this.$events.emit("list", "temp");

        Toastr.send('asdfg')
    },
    data() {
        return {
            loading: false,
            finished: false,
            page: 1,
            news: [
                {
                    title: "人生就是越努力越幸运！",
                    img:
                        "https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2534506313,1688529724&fm=26&gp=0.jpg",
                    date: "2020-06-09",
                    user: "余生非常美",
                    desc:
                        "“生活中再平凡的小事,也要用心做,才会变成永恒故事.”他们在自己平凡的岗位上默默付出,用点滴日夜里的细细耕作,融入美好时代的伟大进程."
                },
                {
                    title: "b",
                    img:
                        "https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2534506313,1688529724&fm=26&gp=0.jpg",
                    user: "余生很美"
                }
            ]
        };
    },
    methods: {
        load() {
            if (this.page > 10) {
                this.finished = true;
                return false;
            }
            this.loading = true;
            setTimeout(() => {
                for (var i = 0; i < 3; i++) {
                    this.news.push({
                        title: "人生就是越努力越幸运！" + i,
                        img:
                            "https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2534506313,1688529724&fm=26&gp=0.jpg",
                        date: "2020-06-09",
                        user: "余生非常美",
                        desc: "生活。。。"
                    });
                }
                this.page++;
                this.loading = false;
            }, 500);
        },
        clickNews(event) {
            console.log(event);
        }
    }
};
</script>

